package com.ruyuan.user.api.model.enums;

import java.util.Arrays;

/**
 * @author xx
 */
public enum AuthResourceTypeEnum {

    MENU("menu", "菜单资源"),
    OPERATION("operation", "操作资源"),
    API("api", "接口资源"),
    DATA("data", "数据资源");

    private String code;

    private String description;

    AuthResourceTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static AuthResourceTypeEnum getByCode(String code) {
        return Arrays.stream(AuthResourceTypeEnum.values()).filter(type -> type.getCode().equals(code)).findFirst().orElse(null);
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
